<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The assignRef purpose</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-view-simple.assign.html">Yaf_View_Simple::assign</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-view-simple.clear.html">Yaf_View_Simple::clear</a></div>
 <div class="up"><a href="class.yaf-view-simple.html">Yaf_View_Simple</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="yaf-view-simple.assignref" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_View_Simple::assignRef</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_View_Simple::assignRef</span> &mdash; <span class="dc-title">The assignRef purpose</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-view-simple.assignref-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>Yaf_View_Simple::assignRef</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter reference">&$value</code></span>
   )</div>

  <p class="para rdfs-comment">
    不同于<span class="methodname"><a href="yaf-view-simple.assign.html" class="methodname">Yaf_View_Simple::assign()</a></span>，这个方法传递一个引用变量给模板引擎
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-view-simple.assignref-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">name</code></em></dt>

    <dd>

     <p class="para">
       一个字符串的名字，被用来传递值给模板。
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">value</code></em></dt>

    <dd>

     <p class="para">
      mixed value
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-view-simple.assignref-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-view-simple.assignref-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4045">
   <p><strong>Example #1 <span class="function"><strong>Yaf_View_Simple::assignRef()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">IndexController&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Yaf_Controller_Abstract&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">indexAction</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"bar"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getView</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;plz&nbsp;note&nbsp;that&nbsp;there&nbsp;was&nbsp;a&nbsp;bug&nbsp;before&nbsp;Yaf&nbsp;2.1.4,&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;which&nbsp;make&nbsp;following&nbsp;output&nbsp;"bar";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$dummy&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getView</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">render</span><span style="color: #007700">(</span><span style="color: #DD0000">"index/index.phtml"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//prevent&nbsp;the&nbsp;auto-render<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">autoRender</span><span style="color: #007700">(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-4046">
   <p><strong>Example #2 <span class="function"><strong>template()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
&lt;html&gt;<br />&nbsp;&lt;head&gt;<br />&nbsp;&nbsp;&lt;title&gt;<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$foo</span><span style="color: #007700">;&nbsp;&nbsp;</span><span style="color: #0000BB">$foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"changed"</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;</span>&lt;/title&gt;<br />&nbsp;&lt;/head&gt;&nbsp;&nbsp;<br />&lt;body&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
/* access the index controller will result: */
changed
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-view-simple.assignref-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="yaf-view-simple.assign.html" class="methodname" rel="rdfs-seeAlso">Yaf_View_Simple::assign()</a> - 为视图引擎分配一个模板变量</span></li>
   <li class="member"><span class="methodname"><a href="yaf-view-simple.set.html" class="methodname" rel="rdfs-seeAlso">Yaf_View_Simple::__set()</a> - 为视图引擎分配一个模板变量</span></li>
  </ul>                       
 </div>
  

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-view-simple.assign.html">Yaf_View_Simple::assign</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-view-simple.clear.html">Yaf_View_Simple::clear</a></div>
 <div class="up"><a href="class.yaf-view-simple.html">Yaf_View_Simple</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
